set
Associates the specified key
with the specified value
. If this map contains a value associated with the key
, it will be replaced.
The type mapping rules are the following:
| Java | JavaScript |
|--------------------|-------------------------------|
| Double | Number |
| String | String |
| Boolean | Boolean |
| null | null |
| JsObject | Object |
| Node | Node |
| List<?> | Array or Proxy Object |
| Set<?> | Set or Proxy Object |
| Map<?,?> | Map or Proxy Object |
| byte[] | ArrayBuffer |
| Object | Proxy Object |
If you pass a non-primitive Java object to JavaScript, it will be converted into a "proxy" JavaScript object. Method and property calls to this object will be delegated to the Java object. For security reasons, JavaScript can access only those methods and fields of the injected Java object that are explicitly marked as accessible either using the JsAccessible annotation or via the JsAccessibleTypes class.
Java collections that are not made accessible to JavaScript using the JsAccessible annotation or via the JsAccessibleTypes class are converted to JavaScript collections. The content of the converted collection is a deep copy of the Java collection. Modifications of the converted collection in JavaScript do not affect the collection in Java.
Java collections that are made accessible to JavaScript using the JsAccessible annotation or via the JsAccessibleTypes class are wrapped into a JavaScript proxy object. Such proxy objects can be used to modify the collection in Java.
Return
this map
Parameters
the key to associate the value
with
the value to be associated with the key